home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / include / gsl / gsl_multiroots.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-20  |  7.7 KB  |  220 lines

  1. /* multiroots/gsl_multiroots.h
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef __GSL_MULTIROOTS_H__
  21. #define __GSL_MULTIROOTS_H__
  22.  
  23. #include <stdlib.h>
  24. #include <gsl/gsl_math.h>
  25. #include <gsl/gsl_vector.h>
  26. #include <gsl/gsl_matrix.h>
  27.  
  28. #undef __BEGIN_DECLS
  29. #undef __END_DECLS
  30. #ifdef __cplusplus
  31. # define __BEGIN_DECLS extern "C" {
  32. # define __END_DECLS }
  33. #else
  34. # define __BEGIN_DECLS /* empty */
  35. # define __END_DECLS /* empty */
  36. #endif
  37.  
  38. __BEGIN_DECLS
  39.  
  40. /* Definition of vector-valued functions with parameters based on gsl_vector */
  41.  
  42. struct gsl_multiroot_function_struct
  43. {
  44.   int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
  45.   size_t n;
  46.   void * params;
  47. };
  48.  
  49. typedef struct gsl_multiroot_function_struct gsl_multiroot_function ;
  50.  
  51. #define GSL_MULTIROOT_FN_EVAL(F,x,y) (*((F)->f))(x,(F)->params,(y))
  52.  
  53. int gsl_multiroot_fdjacobian (gsl_multiroot_function * F,
  54.                               const gsl_vector * x, const gsl_vector * f,
  55.                               double epsrel, gsl_matrix * jacobian);
  56.  
  57.  
  58. typedef struct
  59.   {
  60.     const char *name;
  61.     size_t size;
  62.     int (*alloc) (void *state, size_t n);
  63.     int (*set) (void *state, gsl_multiroot_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
  64.     int (*iterate) (void *state, gsl_multiroot_function * function, gsl_vector * x, gsl_vector * f, gsl_vector * dx);
  65.     void (*free) (void *state);
  66.   }
  67. gsl_multiroot_fsolver_type;
  68.  
  69. typedef struct
  70.   {
  71.     const gsl_multiroot_fsolver_type * type;
  72.     gsl_multiroot_function * function ;
  73.     gsl_vector * x ;
  74.     gsl_vector * f ;
  75.     gsl_vector * dx ;
  76.     void *state;
  77.   }
  78. gsl_multiroot_fsolver;
  79.  
  80. gsl_multiroot_fsolver * 
  81. gsl_multiroot_fsolver_alloc (const gsl_multiroot_fsolver_type * T, 
  82.                                      size_t n); 
  83.  
  84. void gsl_multiroot_fsolver_free (gsl_multiroot_fsolver * s);
  85.  
  86. int gsl_multiroot_fsolver_set (gsl_multiroot_fsolver * s, 
  87.                                gsl_multiroot_function * f, gsl_vector * x);
  88.  
  89. int gsl_multiroot_fsolver_iterate (gsl_multiroot_fsolver * s);
  90.  
  91. const char * gsl_multiroot_fsolver_name (const gsl_multiroot_fsolver * s);
  92. gsl_vector * gsl_multiroot_fsolver_root (const gsl_multiroot_fsolver * s);
  93.  
  94. /* Definition of vector-valued functions and gradient with parameters
  95.    based on gsl_vector */
  96.  
  97. struct gsl_multiroot_function_fdf_struct
  98. {
  99.   int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
  100.   int (* df) (const gsl_vector * x, void * params, gsl_matrix * df);
  101.   int (* fdf) (const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix *df);
  102.   size_t n;
  103.   void * params;
  104. };
  105.  
  106. typedef struct gsl_multiroot_function_fdf_struct gsl_multiroot_function_fdf ;
  107.  
  108. #define GSL_MULTIROOT_FN_EVAL_F(F,x,y) ((*((F)->f))(x,(F)->params,(y)))
  109. #define GSL_MULTIROOT_FN_EVAL_DF(F,x,dy) ((*((F)->df))(x,(F)->params,(dy)))
  110. #define GSL_MULTIROOT_FN_EVAL_F_DF(F,x,y,dy) ((*((F)->fdf))(x,(F)->params,(y),(dy)))
  111.  
  112. typedef struct
  113.   {
  114.     const char *name;
  115.     size_t size;
  116.     int (*alloc) (void *state, size_t n);
  117.     int (*set) (void *state, gsl_multiroot_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
  118.     int (*iterate) (void *state, gsl_multiroot_function_fdf * fdf, gsl_vector * x, gsl_vector * f, gsl_matrix * J, gsl_vector * dx);
  119.     void (*free) (void *state);
  120.   }
  121. gsl_multiroot_fdfsolver_type;
  122.  
  123. typedef struct
  124.   {
  125.     const gsl_multiroot_fdfsolver_type * type;
  126.     gsl_multiroot_function_fdf * fdf ;
  127.     gsl_vector * x;
  128.     gsl_vector * f;
  129.     gsl_matrix * J;
  130.     gsl_vector * dx;
  131.     void *state;
  132.   }
  133. gsl_multiroot_fdfsolver;
  134.  
  135. gsl_multiroot_fdfsolver *
  136. gsl_multiroot_fdfsolver_alloc (const gsl_multiroot_fdfsolver_type * T,
  137.                                       size_t n);
  138.  
  139. int
  140. gsl_multiroot_fdfsolver_set (gsl_multiroot_fdfsolver * s, 
  141.                              gsl_multiroot_function_fdf * fdf,
  142.                              gsl_vector * x);
  143.  
  144. int
  145. gsl_multiroot_fdfsolver_iterate (gsl_multiroot_fdfsolver * s);
  146.  
  147. void
  148. gsl_multiroot_fdfsolver_free (gsl_multiroot_fdfsolver * s);
  149.  
  150. const char * gsl_multiroot_fdfsolver_name (const gsl_multiroot_fdfsolver * s);
  151. gsl_vector * gsl_multiroot_fdfsolver_root (const gsl_multiroot_fdfsolver * s);
  152.  
  153. int gsl_multiroot_test_delta (const gsl_vector * dx, const gsl_vector * x, 
  154.                               double epsabs, double epsrel);
  155.  
  156. int gsl_multiroot_test_residual (const gsl_vector * f, double epsabs);
  157.  
  158. #ifdef GSL_EXPORTS
  159. __declspec(dllexport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_dnewton;
  160. #elif defined(GSL_IMPORTS)
  161. __declspec(dllimport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_dnewton;
  162. #else
  163. extern const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_dnewton;
  164. #endif
  165. #ifdef GSL_EXPORTS
  166. __declspec(dllexport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_broyden;
  167. #elif defined(GSL_IMPORTS)
  168. __declspec(dllimport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_broyden;
  169. #else
  170. extern const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_broyden;
  171. #endif
  172. #ifdef GSL_EXPORTS
  173. __declspec(dllexport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrid;
  174. #elif defined(GSL_IMPORTS)
  175. __declspec(dllimport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrid;
  176. #else
  177. extern const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrid;
  178. #endif
  179. #ifdef GSL_EXPORTS
  180. __declspec(dllexport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrids;
  181. #elif defined(GSL_IMPORTS)
  182. __declspec(dllimport) const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrids;
  183. #else
  184. extern const gsl_multiroot_fsolver_type * gsl_multiroot_fsolver_hybrids;
  185. #endif
  186.  
  187. #ifdef GSL_EXPORTS
  188. __declspec(dllexport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_newton;
  189. #elif defined(GSL_IMPORTS)
  190. __declspec(dllimport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_newton;
  191. #else
  192. extern const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_newton;
  193. #endif
  194. #ifdef GSL_EXPORTS
  195. __declspec(dllexport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_gnewton;
  196. #elif defined(GSL_IMPORTS)
  197. __declspec(dllimport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_gnewton;
  198. #else
  199. extern const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_gnewton;
  200. #endif
  201. #ifdef GSL_EXPORTS
  202. __declspec(dllexport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridj;
  203. #elif defined(GSL_IMPORTS)
  204. __declspec(dllimport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridj;
  205. #else
  206. extern const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridj;
  207. #endif
  208. #ifdef GSL_EXPORTS
  209. __declspec(dllexport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridsj;
  210. #elif defined(GSL_IMPORTS)
  211. __declspec(dllimport) const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridsj;
  212. #else
  213. extern const gsl_multiroot_fdfsolver_type * gsl_multiroot_fdfsolver_hybridsj;
  214. #endif
  215.  
  216.  
  217. __END_DECLS
  218.  
  219. #endif /* __GSL_MULTIROOTS_H__ */
  220.